package edu.fjut.se1603.yuan.util;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class CheckAccount {
    public static Integer check(String table,String name,String password){
        Integer flag=null;
        Connection conn=DBUtil.getConnection();
        try {
            PreparedStatement ps=conn.prepareStatement("select ID from "+table+" where NAME=? and PASSWORD=?");
            ps.setString(1,name);
            ps.setString(2,password);
            ResultSet rs=ps.executeQuery();
            if(rs.next())
                flag=rs.getInt("ID");
        } catch (SQLException e) {
            e.printStackTrace();
        }finally {
            DBUtil.closeAll(conn);
        }
        return flag;
    }
}
